#!/usr/bin/env python
# encoding: utf-8

import sys
import os

class go_node:
	"""
	Container class for the entries in gene ontology file.
	"""
	
	def __init__(self, id=-1, name="", description="", namespace="", definition="", isa=[]):
		self.id = id
		self.name = name
		self.description = description
		self.namespace = namespace
		self.definition = definition
		self.isa = isa
		
	def __str__(self):
		return 'GO node, id = ' + str(self.id) + ' name = ' + self.name #+ ' namespace = ' + self.namespace + ' definition = ' + self.definition + ' isa = ' + ','.join([str(i) for i in self.isa])
		
	def __setitem__(self, index, value):
		"""
		Sets details of the node
			node_object['id'] = id_integer
			node_object['name'] = name_string
			node_object['isa'] = isa_list
		etc will work
		"""
		if index == 'id':
			self.id = value
		elif index == 'name':
			self.name = value
		elif index == 'description':
			self.description = value
		elif index == 'namespace':
			self.namespace = value
		elif index == 'definition':
			self.definition = value
		elif index == 'isa':
			self.isa = value

	def __getitem__(self, index):
		"""
		Gets details of the node
		"""
		if index == 'id':
			return self.id
		elif index == 'name':
			return self.name
		elif index == 'namespace':
			return self.namespace
		elif index == 'definition':
			return self.definition
		elif index == 'isa':
			return self.isa